package com.cloud.system.api.provider;

import com.cloud.system.api.bean.UnitPowerCriteriaBean;
import org.apache.ibatis.jdbc.SQL;

public class PowerPageProvider {
    String LIST_PAGE_SELECT = "power_id,power_name,power_type_id,power_type_name,is_involve_criminal,power_state_id,power_state_name,effective_date,expired_date,unit_id,unit_name,is_public",
            LIST_PAGE_FOMR = " unit_power";

    public String listUnitPowerPage(UnitPowerCriteriaBean unitPowerCriteriaBean) {

        SQL sql = new SQL().SELECT(LIST_PAGE_SELECT).FROM(LIST_PAGE_FOMR);

        sql.WHERE( "unit_id = " + unitPowerCriteriaBean.getUnitId());

        if (unitPowerCriteriaBean.getPowerTypeId().size() > 0) {
            sql.WHERE( "power_type_id in (" +String.join(",",unitPowerCriteriaBean.getPowerTypeId()) + ")");
        }

        return sql.toString();
    }

}
